#ifndef FRACTAL_H
#define FRACTAL_H

#include <gdkmm/pixbuf.h>
#include <vector>
#include "gradient.h"
#include "jobqueue.h"
#include "thread.h"

class Fractal {
	public:
		Fractal(int w, int h, double centreX, double centreY, double scale, int limit, int samples);
		~Fractal();
		void generate(int nThreads);
		void abort();
		
		bool isComplete();
		float getProgress();
		Glib::RefPtr<Gdk::Pixbuf> createPixbuf();
		
		void setSize(int w, int h);
		void setW(int w);
		void setH(int h);
		void setLimit(int limit);
		void setCentre(double x, double y);
		void setCentreX(double centreX);
		void setCentreY(double centreY);
		void setScale(double scale);
		void setNSamples(int nSamples);
	
		int getW();
		int getH();
		int getLimit();
		double getCentreX();
		double getCentreY();
		double getScale();
		int getNSamples();
		
		Gradient &getGradient();
	
	private:
		double *downSample();
		int w_, h_;
		int limit_;
		double centreX_;
		double centreY_;
		double scale_;
		double *samples_;
		int nSamples_;
		Gradient gradient_;
		std::vector <Thread *> threads_;
		JobQueue jobQueue_;
};

#endif
